package com.yunxi.service.dubboService.impl.account;

import com.github.pagehelper.PageInfo;
import com.yunxi.account.pojo.AccountGroupPropVO;
import com.yunxi.account.service.AccountGroupPropDubboService;
import com.yunxi.core.web.LoginInfo;
import com.yunxi.model.account.AccountGroupProp;
import com.yunxi.service.localService.account.AccountGroupPropService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

/**
 * <p>
 * 账户组属性 服务实现类
 * </p>
 *
 * @author
 * @since 2019-05-20
 */
//@com.alibaba.dubbo.config.annotation.Service(version = "${demo.service.version}",
//        application = "${dubbo.application.id}",
//        protocol = "${dubbo.protocol.id}",
//        registry = "${dubbo.registry.id}"
//)
public class AccountGroupPropDubboServiceImpl implements AccountGroupPropDubboService {

   @Autowired
   @Qualifier(value = "accountGroupPropServiceImpl")
   AccountGroupPropService accountGroupPropService;


   @Override
   public AccountGroupPropVO getById(String id) throws InvocationTargetException, IllegalAccessException {
      AccountGroupProp accountGroupProp = accountGroupPropService.getById(id);
      AccountGroupPropVO accountGroupPropVO = new AccountGroupPropVO();
      BeanUtils.copyProperties(accountGroupProp, accountGroupPropVO);
      return accountGroupPropVO;
   }

   @Override
   public void saveOrUpdate(AccountGroupPropVO accountGroupPropVO, LoginInfo loginInfo) throws InvocationTargetException, IllegalAccessException {
      if (StringUtils.isEmpty(accountGroupPropVO.getAccountPropId())) {
         accountGroupPropVO.setCreateBy(loginInfo.getRealName());
      }
      accountGroupPropVO.setUpdateBy(loginInfo.getRealName());
      AccountGroupProp accountGroupProp = new AccountGroupProp();
      BeanUtils.copyProperties(accountGroupPropVO, accountGroupProp);
      accountGroupPropService.saveOrUpdate(accountGroupProp);
   }

   @Override
   public void removeById(String id, LoginInfo loginInfo) {
      accountGroupPropService.removeById(id);
   }

   @Override
   public PageInfo<AccountGroupPropVO> findPageByVO(AccountGroupPropVO accountGroupPropVO, Integer pageNum, Integer pageSize) throws InvocationTargetException, IllegalAccessException {

      PageInfo<AccountGroupPropVO> pageInfo = accountGroupPropService.pageByVo(accountGroupPropVO, pageNum, pageSize);

      return pageInfo;

   }

   @Override
   public List listByVo(AccountGroupPropVO accountGroupPropVO) {
      return accountGroupPropService.listByVo(accountGroupPropVO);
   }

}
